﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Xml;

namespace YaksueGraphicsConfigGUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            XmlDocument doc = new XmlDocument();
            doc.Load("ApplicationConfig.xml");

            XmlElement config = (XmlElement)doc.SelectSingleNode("ApplicationConfig");

            //图形API：
            option_graphicsAPI.Text = config.GetAttribute("GraphicsAPITypeName");
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Save();
        }

        private void Save()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("ApplicationConfig.xml");

            XmlElement config = (XmlElement)doc.SelectSingleNode("ApplicationConfig");

            config.SetAttribute("GraphicsAPITypeName", option_graphicsAPI.Text);

            doc.Save("ApplicationConfig.xml");
        }
    }
}
